package 力扣日常刷题.木23一月.第14天314;

import 力扣日常刷题.TreeNode;

/**
 * @author 帅小伙
 * @date 2022/3/14
 * @description
 */
public class Demo66路径总和 {

    public boolean hasPathSum(TreeNode root,int sum) {
        if (root == null) return false;

        if(root.left == null && root.right == null) {
            return root.val == sum;
        }
        return hasPathSum(root.left,sum - root.val) || hasPathSum(root.right,sum - root.val);
    }

}
